app.controller('seven', function ($scope, $rootScope, $http, $interval, $compile, $state,$filter) {
    //修改案例状态
    //修改案例状态
    $scope.changeStatus = function () {
        if(!$scope.caseId){
            return;
        }
        /*if($scope.item.optionItem == "请选择时间"){
            $rootScope.tipPopups.show(($rootScope.tipMessage = "请选择时间"));
            return;
        }*/
        var remark = $(".remark").val();
        if(remark.length > 200){
            $rootScope.tipPopups.show(($rootScope.tipMessage = "备注字数不能超过200个字"));
            return;
        }
        if(remark.length == 0){
            $rootScope.tipPopups.show(($rootScope.tipMessage = "备注字数不能为空"));
            return;
        }
        var postData = {
            "caseId": $scope.caseId,
            "status": $scope.status,
            "optionItem": $scope.paramDate,
            "urls": ""
        }
        postData.remark = $(".remark").val();
        console.log($(".remark"))
        console.log(postData);
        postHttp($http, 'installtionCase/updateCaseStatus', postData, function (res) {
            if (res.code === 0 && res.msg == "success") {
                $state.go(one.stateName);
            } else {
                $rootScope.tipPopups.show(($rootScope.tipMessage = res.msg));
            }
        });
    }

    $scope.disableKeyboard = function () {
        document.activeElement.blur();
    }


    //录入基本信息
	$scope.fourteen = function(){
	    if(1==$scope.c){  //选中 “是”
            $state.go(fourteen.stateName);
        }else{
            $state.go(az2.stateName);
        }
	}

    $scope.showBottomLayer = function(type){
		document.getElementById('debuginfo').innerHTML=type;
        $scope.selectDate(2);
    }

    //开盘时间and //入住时间
    $scope.selectDate = function(type) {
        var day = new Date();
        var myJsDate=$filter('date')($scope.dueDate,'yyyy-MM-dd');
        var day2 = new Date(myJsDate);
        if(day.getTime() >= day2.getTime()){
            $rootScope.tipPopups.show(($rootScope.tipMessage = "截止日期小于当前日期无法改期"));
            return;
        }

        $(".weui-picker").css("display","block");
        weui.datePicker({
            start: new Date(day.getFullYear(),(day.getMonth()),day.getDate()),
            end: new Date(day2.getFullYear(),(day2.getMonth()),day2.getDate()),
            id: 'bottomLayer',
            onChange: function (result) {
                // console.log(result);
            },
            onConfirm: function (result) {
                if (result && result.length > 0) {
                     value = '';
                    for (var i in result) {
                        value += result[i].label;
                    }
                    var time = value;
                    time = time.replace(/[^(\\u4e00-\\u9fa5)]/g, '/');
                    time = time.substring(0, time.length - 1);
                    console.log(new Date(time));
                    $scope.item.optionItem = time;

                    $scope.$applyAsync();
                }
            }
        });
    }
    //初始化
    function init(){
        //案例id
        $scope.caseId = seven.params.caseId;
        if(!seven.params.caseId){
            $scope.caseId = localStorage.getItem("sdm-caseId");
        }
        $scope.dueDate = seven.params.dueDate;

        $scope.status = 3;
        $scope.item = {
            optionItem:'请选择时间'
        };
    }
    
   init();

    reloadJs();
});